package prickworlds.gui;

import static org.lwjgl.opengl.GL11.*;
import prickworlds.structure.KeyEvent;
import prickworlds.structure.MouseEvent;

public class ProgressBar extends Control {
	/**
	 * value from 0.0f to 1.0f
	 */
	private float filled;

	public ProgressBar(int x, int y, int width, int height) {
		super(x, y, width, height);
	}

	@Override
	public void display() {
		glColor3f(0f, 0.6f, 0f);
		glBegin(GL_TRIANGLE_STRIP);

		glVertex2f(x, y);
		glVertex2f(x + width * filled, y);
		glVertex2f(x, y + height);
		glVertex2f(x + width * filled, y + height);

		glEnd();

		glColor3f(0.3f, 0.3f, 0.3f);
		glBegin(GL_TRIANGLE_STRIP);

		glVertex2f(x + width * filled, y);
		glVertex2f(x + width, y);
		glVertex2f(x + width * filled, y + height);
		glVertex2f(x + width, y + height);

		glEnd();
	}

	@Override
	public void update() {
	}

	@Override
	public void handleKeyEvent(KeyEvent event) {
	}

	@Override
	public void handleMouseEvent(MouseEvent event) {
	}

	public void setPercentage(float percentage) {
		filled = percentage / 100.0f;
	}

	public float getPercentage() {
		return filled * 100.0f;
	}

}
